# Maintainer: Jeroen Ooms <jeroenooms@gmail.com>

_realname=raptor2
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.0.15
pkgrel=1
pkgdesc="RDF Parser Toolkit (mingw-w64)"
arch=('any')
url='http://librdf.org/raptor/'
license=('LICENSE')
source=("http://download.librdf.org/source/${_realname}-${pkgver}.tar.gz"
        no-undefined.patch)
sha256sums=('ada7f0ba54787b33485d090d3d2680533520cd4426d2f7fb4782dd4a6a1480ed'
            'f2e8e607f0b735255c0ba61346ad978ff934dc726c25b62942afe5c6decded13')

depends=("${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-curl")

prepare() {
  cd $srcdir/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/no-undefined.patch

  autoreconf -fiv
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  CFLAGS="-DNESTED_QSORT -DRAPTOR_STATIC -DIN_LIBXML" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-debug \
    --disable-dependency-tracking \
    --with-www=none

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
